import { NextRequest, NextResponse } from "next/server"

import prisma from "@/lib/prisma"

export const GET = async (req: Request, { appId }: { appId: string }) => {
    const data = await prisma.chatSession.findMany({ where: { appId } })
    return NextResponse.json(data)
}

export const POST = async (req: Request) => {
    const body = await req.json()
    const data = await prisma.chatSession.create({ data: body })

    return NextResponse.json(data)
}